<?php use_helper('Object') ?>

<h1>Verwaltung</h1>
<ul id="nav-left">
<?php foreach ($locations as $location): ?>
   <?php if(!empty($request_id) && $request_id == $location->getId()): ?>
   <li class="active"><?php echo link_to('&raquo; '.$location->getName(), 'management/showOverview?id='.$location->getId().'&dest=location') ?> (<?php echo link_to('E', 'management/showOverview?id='.$location->getId().'&dest=location&view=editLocation') ?>)
   <?php $selected_location = $location;  ?>
   <?php else: ?>
   <li><?php echo link_to('&raquo; '.$location->getName(), 'management/showOverview?id='.$location->getId().'&dest=location') ?> (<?php echo link_to('E', 'management/showOverview?id='.$location->getId().'&dest=location&view=editLocation') ?>)
   <?php endif; ?>
<?php if(!empty($request_id) && $request_id == $location->getId()): ?>
	<ul>
	<?php foreach ($hardwares as $hardware): ?>
	   <?php if(!empty($request_hid) && $request_hid == $hardware->getId()): ?>
	   <li class="active"><?php echo link_to('&raquo; '.$hardware->getBezeichnung(), 'management/showOverview?id='.$location->getId().'&hid='.$hardware->getId().'&view=viewSoftware') ?> (<?php echo link_to('E', 'management/showOverview?id='.$location->getId().'&hid='.$hardware->getId().'&view=editHardware&dest=hardware') ?>)</li>  
	   <?php else: ?>
	   <li><?php echo link_to('&raquo; '.$hardware->getBezeichnung(), 'management/showOverview?id='.$location->getId().'&hid='.$hardware->getId().'&view=viewSoftware') ?>  (<?php echo link_to('E', 'management/showOverview?id='.$location->getId().'&hid='.$hardware->getId().'&view=editHardware&dest=hardware') ?>)</li>
	   <?php endif; ?>	
	<?php endforeach; ?>
	</ul> 
<?php endif; ?>
</li>      
<?php endforeach; ?>
</ul>
<div id="content-right">
<?php if ($sf_flash->has('errMessage')): ?>
  <div class="message"><?php echo $sf_flash->get('errMessage') ?></div>
<?php endif; ?>

<?php if($request_view == 'editLocation' && $request_dest == 'location'): ?>
<?php include_partial('editLocation', array('location' => $selected_location)) ?>
<?php endif; ?>
<?php if($request_view == 'editHardware' && $request_dest == 'hardware' && !empty($request_id)): ?>
<?php include_partial('editHardware', array('hardware' => $selected_hardware)) ?>
<?php endif; ?>
<?php if($request_view == 'viewSoftware' && !empty($request_hid)): ?>
<?php include_partial('viewSoftware', array('hardware' => $selected_hardware, 'location' => $selected_location)) ?>
<?php endif; ?>
<?php if($request_view == 'updateSoftware' && $request_dest == 'hardware' && !empty($request_hid)): ?>
<?php include_partial('updateSoftware', array('location' => $selected_location, 'hardware' => $selected_hardware, 'software' => $selected_software, 'request_id' => $request_id, 'request_cid' => $request_cid, 'request_hid' => $request_hid, 'installed_software' => $installed_software)) ?>
<?php endif; ?>
</div>
<div class="clear"></div>

<?php #print_r($selected_hardware->getAllSoftware()) ?>

<fieldset>
<legend>Funktionen</legend>

<?php echo link_to('Standort hinzufügen', 'management/showOverview?dest=location&view=editLocation') ?>
<?php if(!empty($request_id)): ?>
|<?php echo link_to('Rechner hinzufügen', 'management/showOverview?id='.$selected_location->getId().'&dest=hardware&view=editHardware') ?>
<?php endif; ?>
<?php if(!empty($request_hid)): ?>
|<?php echo link_to('Software hinzufügen', 'management/showOverview?id='.$selected_location->getId().'&hid='.$selected_hardware->getId().'&dest=hardware&view=updateSoftware') ?>
<?php endif; ?>
</fieldset>